//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    imgurl:[]
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    wx.request({
      method: "GET",
      url: "https://xcs.ddks8888.com/index.php/WXAPI/index/home",

      data: {

      },
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {

      
        if (res.data.result != 0) {
          //console.log(res.data.data)
          //将图片从接口拿过来，并且用七牛参数处理一下
          var bannerImg = [];
          // _.each(res.data.data.banner,function(v,i){
          //     bannerImg.push(ajaxUrl.cdnUrl() + v.image+"?imageView2/1/w/750/h/380/q/60");
          // })
        
            bannerImg.push(res.data.ad[1].ad_code);

          }
          //console.log(that.setData);
          that.setData({
            'imgurl': bannerImg
          })
        }

      
    })





    
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  }
})
